import avueMonacoEdit from "./avue-monaco-edit/index.vue";
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';


import avueWangEditor from "components/avue-extension/avue-wang-editor/index.vue";

const components = [avueMonacoEdit, avueWangEditor]

export default {
    install(app) {
        self.MonacoEnvironment = {
            getWorker(_, label) {
                if (label === 'json') {
                    return new jsonWorker();
                }
                if (label === 'css' || label === 'scss' || label === 'less') {
                    return new cssWorker();
                }
                if (label === 'html' || label === 'handlebars' || label === 'razor') {
                    return new htmlWorker();
                }
                if (label === 'typescript' || label === 'javascript') {
                    return new tsWorker();
                }
                return new editorWorker();
            },
        };
        // console.log("monaco",monaco)
        // monaco.editor.setLocale('zh-cn');
        for (const component of components) {
            app.component(component.name, component);
        }


    }
}
